<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<div id="header" class="wrap">
    <!-- 导航栏信息 -->
    <div id="logo">
        <img src="./images/logo.gif">
    </div>
    <div class="help">
        <c:choose >
            <c:when test="${not empty currentUser}">
                <!--已经登录-->
                <a href="shopping?oper=list" class="shopping">
                    购物车(${shoppingCart.shoppingCartItems ==null ? 0 : shoppingCart.shoppingCartItems.size()})件商品</a>
                <a href="userServlet?oper=userCenter">${currentUser.userName}</a>
                <a href="javascript:logout()">注销</a>
                <%--<a href="register.jsp">注册</a>--%>
                <a href="comment?oper=list">留言板</a>
            </c:when>
            <c:otherwise>
                <!--未登录-->

                <a href="javascript:checkLogin()" class="shopping">购物车</a>
                <a href="login.jsp">登录</a>
                <a href="register.jsp">注册</a>
                <a href="javascript:checkLogin()">留言板</a>
            </c:otherwise>
        </c:choose>
        <form action="search" method="get">
            <input type="hidden" name="bigTypeId" value="${bigTypeId}" />
            <input type="hidden" name="smallTypeId" value="${smallTypeId}" />
            <input type="text" name="keyword" value="${keyword}" ><!-- autocomplete="off" -->
            <input type="submit" value="搜索">
        </form>
    </div>


    <div class="navbar">
        <ul class="clearfix">
            <li <c:if test="${empty bigTypeId}">class="current"</c:if> ><a href="index">首页</a></li>
            <!--后台读取数据并展示-->
            <c:forEach items="${bigTypes}" var="bigType" >
                <li <c:if test="${bigTypeId == bigType.id }" >class="current"</c:if> >
                    <a href="search?bigTypeId=${bigType.id}">${bigType.name}</a>
                </li>
            </c:forEach>
        </ul>
    </div>

    <div id="childNav">
        <div class="wrap">
            <ul class="clearfix">

                <c:forEach items="${tags}" var="tag" varStatus="varStatus"  >
                    <!--只有第一个li才有first样式-->
                    <li <c:if test="${varStatus.first}"> class="first" </c:if> <c:if test="${varStatus.last}" >class="last"</c:if>  >
                        <a href="${tag.url}">${tag.name}</a>
                    </li>
                </c:forEach>


            </ul>
        </div>
    </div>

    <script type="text/javascript">
        function checkLogin() {
            if ('' == '') {
                alert("请先登录");
            } else {
                window.laction.href = "shopping?oper=list";
            }
        }

        function logout() {
            if (confirm('您确定要退出系统吗 ? ')) {
                window.location.href = "userServlet?oper=logout";
            }
        }
    </script>

</div>
